<template>
	<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption"  @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
		<stop isBack>
			<view slot="content">出入库定单</view>
		</stop>
		<view class="bcf padlr3 padtb2 bdtso">
			<search class="fs8 tac" placeholder=" 单号 \ 物资名称 \ 编码 \ 型号"  v-model="search" @search="doSearch()"></search>
		</view>
		<!-- <sradiomodel="MachineBreakLevel" v-model="where.eq.level"></sradio> -->
		<view class="padlr3">
			<view class="bcf pos-r mart3 pad2 round2 shadow" 
			v-for="log in data" :key="log.id">
				<store-form :item="log"></store-form>
				<view class="bdtso lh2">
					<view class="pad2 flex-end" v-if="isnull(log.checkAt)">
						<view class="cu-btn lg bg-orange round" @tap="deleteIt(log.id)">删除 <ripple></ripple></view>
						<view class="cu-btn lg bg-green round marl10" @tap="confirm(log.id)">确认<ripple></ripple></view>
					</view>
				</view>
			</view>
		</view>
		<loading :loading="myIsLoading"></loading>
	</scroll>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import List from '../../assets/js/list.js'
	
	import storeForm from '../../templete/store/store_form_item.vue'
	
	export default {
		mixins:[MescrollMixin],
		components:{storeForm},
		data() {
			let list = new List()
			return {
				list,
				where:{
					eq:{
						status:'',
						emergency:'',
						level:'',
					}
				},
				search:"",
				data:[]
			}
		},
		methods: {
			reload(){
				this.showLoading()
				this.data=[]
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			doSearch(){
				this.showLoading()
				this.data=[]
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			confirm(id){
				// this.$api.post('/api/storeIns/confirm/'+id,{},res=>{
				// 	this.reload()
				// })
				this.goto('/pages/store/store_in_check_form?id=' + id)
			},
			deleteIt(id){
				this.$api.delete('/api/storeIns/'+id,{},res=>{
					this.log(res)
					this.reload()
				})
			}
		},
		mounted() {
			this.list.initMescroll(this).setUrl('/api/storeIns').setData({
				_order:{id:"DESC"},
				_where:this.where,
				_search:this.search,
			}).setCbFunc(res=>{
				this.data = res
				this.clearLoading()
			}).reload()
		},
		onShow() {
			this.log("onshow")
			this.showLoading()
			this.list.reload()
		},
		watch:{
		}
	}
</script>

<style>

</style>
